//
//  FQDArticleCellBottomView.m
//  FakeQDaily
//
//  Created by mewxiv on 8/15/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import "FQDArticleCellBottomView.h"
#import "UIButton+FQDExtension.h"

#import "Masonry.h"

@implementation FQDArticleCellBottomView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self prepareUI];
        [self prepareConstraints];
    }
    return self;
}

- (void)prepareUI
{
    _categoryLabel = [[UILabel alloc] init];
    _categoryLabel.font = FQDRegularFontWithSize(12.0f);
    _categoryLabel.textColor = FQDFeedDetailTextColor;
    _categoryLabel.text = @"";
    _categoryLabel.backgroundColor = [UIColor whiteColor];
    _categoryLabel.clipsToBounds = YES;
    [self addSubview:_categoryLabel];
    
    _commentButton = [UIButton commentButtonWithCommentNum:17];
    _commentButton.titleLabel.backgroundColor = [UIColor whiteColor];
    _commentButton.titleLabel.clipsToBounds = YES;
    [self addSubview:_commentButton];
    
    _praiseButton = [UIButton praiseButtonWithPraiseNum:217];
    _praiseButton.titleLabel.backgroundColor = [UIColor whiteColor];
    _praiseButton.titleLabel.clipsToBounds = YES;
    [self addSubview:_praiseButton];
    
    _dateLabel = [[UILabel alloc] init];
    _dateLabel.font = FQDRegularFontWithSize(12.0f);
    _dateLabel.textColor = FQDFeedDetailTextColor;
    _dateLabel.backgroundColor = [UIColor whiteColor];
    _dateLabel.clipsToBounds = YES;
    [self addSubview:_dateLabel];
    
}

- (void)prepareConstraints
{
    WeakSelf;
    
    [_categoryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.bottom.equalTo(weakSelf);
    }];
    
    [_commentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.categoryLabel.mas_right).offset(6);
        make.bottom.equalTo(weakSelf.categoryLabel);
    }];
    
    [_praiseButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.commentButton.mas_right).offset(10);
        make.bottom.equalTo(weakSelf.categoryLabel);
    }];
    
    [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.praiseButton.mas_right).offset(8);
        make.bottom.equalTo(weakSelf.categoryLabel);
    }];
}

@end
